function t() {
    o = 1, n = 0, s = 0, a.setData({
        leftlist: new Array(),
        rightlist: new Array(),
        listnum: 0
    }), e(i);
}

function e(t) {
    r.sendrequest("posterapi/getlist", "POST", {
        token: i,
        page: o,
        is_dynamic: u,
        keyword: c,
        cate_id: d,
        label_id: l
    }, function(t) {
        if (1 == t.status) {
            for (var e = new Array(), i = new Array(), r = t.data, o = 0; o < r.length; o++) n > s ? (i.push(r[o]), 
            s += parseInt(r[o].background_height)) : (e.push(r[o]), n += parseInt(r[o].background_height));
            a.setData({
                leftlist: a.data.leftlist.concat(e),
                rightlist: a.data.rightlist.concat(i),
                listnum: a.data.listnum + r.length
            });
        }
    });
}

var a, i, n, s, r = require("../../utils/util.js"), o = 1, d = 0, l = 0, u = 0, c = "", f = getApp().globalData.url.imgurl;

Page({
    data: {
        scrollheight: 450,
        curtagname: "",
        curname: "",
        curid: d,
        keyword: c,
        imgurl: f,
        leftlist: new Array(),
        rightlist: new Array(),
        listnum: 0
    },
    onLoad: function(t) {
        c = "", d = 0, l = 0, u = 0, n = 0, s = 0, o = 1, a = this;
        try {
            var f = wx.getSystemInfoSync();
            this.setData({
                scrollheight: f.windowHeight - 167
            });
        } catch (t) {}
        t.cateid && (d = t.cateid, a.setData({
            curid: d
        })), t.keyword && (c = t.keyword, a.setData({
            keyword: c
        })), t.label_id && (l = t.label_id, a.setData({
            label_id: l
        })), t.is_dynamic && (u = t.is_dynamic), r.getToken(function(t) {
            i = t;
        }), r.sendrequest("posterapi/getclassify", "POST", {
            token: i
        }, function(t) {
            1 == t.status && a.setData({
                classifyList: t.data,
                curname: "cate_" + d
            });
        }), r.sendrequest("posterapi/getlabel", "POST", {
            token: i
        }, function(t) {
            1 == t.status && a.setData({
                labelList: t.data,
                curtagname: "tag_" + l
            });
        }), e();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    more: function(t) {
        wx.reLaunch({
            url: "/pages/index/index"
        });
    },
    lower: function() {
        o += 1, e();
    },
    cingput: function(t) {
        c = t.detail.value;
    },
    submit: function(e) {
        t();
    },
    clabel: function(e) {
        l == e.detail.target.dataset.id ? l = 0 : (c = "", l = e.detail.target.dataset.id, 
        a.setData({
            curid: 0,
            keyword: "",
            curname: "cate_0"
        }), d = 0), this.setData({
            label_id: l
        }), t(), r.getToken(function(t) {
            r.sendrequest("posterapi/setfrom", "POST", {
                token: t,
                formid: e.detail.formId
            }, function(t) {});
        });
    },
    changeCate: function(e) {
        a.setData({
            curid: e.detail.target.dataset.id
        }), d = e.detail.target.dataset.id, l = 0, this.setData({
            label_id: l
        }), t(), r.getToken(function(t) {
            r.sendrequest("posterapi/setfrom", "POST", {
                token: t,
                formid: e.detail.formId
            }, function(t) {});
        });
    },
    redirtbyid: function(t) {
        wx.navigateTo({
            url: "/pages/poster/poster?micro_id=" + t.detail.target.dataset.id
        }), r.getToken(function(e) {
            r.sendrequest("posterapi/setfrom", "POST", {
                token: e,
                formid: t.detail.formId
            }, function(t) {});
        });
    }
});